package il.ac.bgu.cs.heuristics.utils;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import junit.framework.TestCase;

import org.junit.Assert;
import org.junit.Test;

/**
 * 
 * @author Ronen Pinko
 * 
 * 
 */
public class CombinationTests extends TestCase{

	private static final String BANANAS = "bananas";
	private static final String ROOM2 = "room2";
	private static final String ROOM1 = "room1";
	private static final String CHAIR = "chair";
	private static final String MONKEY = "monkey";

	@Test
	public void testCombination01() {
		final Set<String> constants = CollectionUtils.newLinkedHashSet();
		constants.add(MONKEY);
		constants.add(CHAIR);
		constants.add(ROOM1);
		constants.add(ROOM2);
		constants.add(BANANAS);
		final Set<Set<String>> kCombinations = MathUtils.createKCombinations(
		        constants, 3);

		final Set<Set<String>> expected = CollectionUtils.newLinkedHashSet();

		expected.add(new HashSet<String>(Arrays.asList(new String[] { MONKEY,
		        CHAIR, ROOM1 })));
		expected.add(new HashSet<String>(Arrays.asList(new String[] { MONKEY,
		        CHAIR, ROOM2 })));
		expected.add(new HashSet<String>(Arrays.asList(new String[] { MONKEY,
		        CHAIR, BANANAS })));
		expected.add(new HashSet<String>(Arrays.asList(new String[] { MONKEY,
		        ROOM1, ROOM2 })));
		expected.add(new HashSet<String>(Arrays.asList(new String[] { MONKEY,
		        ROOM1, BANANAS })));
		expected.add(new HashSet<String>(Arrays.asList(new String[] { MONKEY,
		        ROOM2, BANANAS })));
		expected.add(new HashSet<String>(Arrays.asList(new String[] { CHAIR,
		        ROOM1, ROOM2 })));
		expected.add(new HashSet<String>(Arrays.asList(new String[] { CHAIR,
		        ROOM1, BANANAS })));
		expected.add(new HashSet<String>(Arrays.asList(new String[] { CHAIR,
		        ROOM2, BANANAS })));
		expected.add(new HashSet<String>(Arrays.asList(new String[] { ROOM1,
		        ROOM2, BANANAS })));

		Assert.assertEquals(expected, kCombinations);
	}
}
